<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>hook_example</title>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body style="height: 1500px;">
    <div id="app">
        <p>Scroll down the page</p>
        <p v-pin:[direction]="200">Stick me 200px from the top of the page</p>
    </div>
    <script>
        Vue.directive('pin', {
            bind: function(el, binding, vnode){
                el.style.position = 'fixed';
                var s = (binding.arg == 'left' ? 'left' : 'top');
                el.style[s] = binding.value + 'px';
            }
        });
        new Vue({
            el: '#app',
            data: function(){
                return {
                    direction: 'left'
                }
            }
        });
    </script>
</body>
</html>
